package com.jungle.bfi.controller;

import com.jungle.base.dao.SpecBuilder;
import com.jungle.base.domain.bo.BaseUserBo;
import com.jungle.base.domain.vo.JsonResult;
import com.jungle.bfi.domain.bo.VoucherEntryTemplateBo;
import com.jungle.bfi.entity.VoucherEntryTemplatePo;
import com.jungle.bfi.service.voucher.VoucherEntryTemplateService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * [voucher]凭证分录模板实体类
 * @author jungle
 * @since 2025-02-19 08:18:02
 */
@Slf4j
@RestController
@RequestMapping("voucherEntryTemplate")
public class VoucherEntryTemplateController {
    @Resource
    private VoucherEntryTemplateService voucherEntryTemplateService;
    @PostMapping("store")
    public JsonResult<VoucherEntryTemplatePo> store(@RequestBody VoucherEntryTemplateBo qo) {
        VoucherEntryTemplatePo po = voucherEntryTemplateService.saveOrUpdate(qo, new BaseUserBo());
        return JsonResult.success(po);
    }

    @PostMapping("list")
    public JsonResult<List<VoucherEntryTemplatePo>> list(@RequestBody VoucherEntryTemplateBo bo) {
        List<VoucherEntryTemplatePo> list = voucherEntryTemplateService.findAll(new SpecBuilder<VoucherEntryTemplatePo>(bo).toSpec());
        return JsonResult.success(list);
    }
}
